home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Circle bulge fade.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  87 lines

  1. /**********************************************************************\
  2.  
  3. File:        Circle bulge fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define    startgap            1
  28. #define    gapratio            6
  29. #define    zeropointH            15
  30. #define CorrectTime 3
  31. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33.  
  34. pascal short CircleBulgeFade(Rect boundsRect, Pattern *thePattern);
  35.  
  36. /* This copies ovals that always run from the left of the screen to the right,
  37.    but start really squashed and get geometrically taller.  */
  38.    
  39. pascal short CircleBulgeFade(Rect boundsRect, Pattern *thePattern)
  40. {
  41.     Rect        theRect;
  42.     RgnHandle    curregion, boundsRgn, sectrgn;
  43.     Point        zeropoint;
  44.     int            cy=theWindowHeight/2;
  45.     int            gap=startgap;
  46.     
  47.     theRect.left=boundsRect.left;
  48.     theRect.right=boundsRect.right;
  49.     theRect.top=boundsRect.top+cy-gap;
  50.     theRect.bottom=boundsRect.top+cy+gap;
  51.         
  52.     boundsRgn=NewRgn();
  53.     RectRgn(boundsRgn, &boundsRect);
  54.     sectrgn=NewRgn();
  55.     curregion=NewRgn();
  56.     zeropoint.v=boundsRect.top;
  57.     zeropoint.h=boundsRect.left+zeropointH;
  58.     do
  59.     {
  60.         StartTiming();
  61.  
  62.         SetEmptyRgn(curregion);
  63.         OpenRgn();
  64.             FrameOval(&theRect);  /* this makes the region for copying */
  65.         CloseRgn(curregion);
  66.  
  67.         SectRgn(curregion, boundsRgn, sectrgn);
  68.         FillRgn(sectrgn, *thePattern);
  69.  
  70.         theRect.top-=gap;
  71.         theRect.bottom+=gap;     /* make the oval taller */
  72.         gap++;
  73.         gap+=gap/gapratio;       /* make the oval grow faster next time */
  74.         
  75.         TimeCorrection(CorrectTime);
  76.     }
  77.     while (!(PtInRgn(zeropoint, curregion)));    /* quit when we hit zeropoint */
  78.  
  79.     FillRect(&boundsRect, *thePattern);            /* fill the whole screen to end it */
  80.     
  81.     DisposeRgn(curregion);
  82.     DisposeRgn(boundsRgn);
  83.     DisposeRgn(sectrgn);
  84.     
  85.     return 0;
  86. }
  87.